package ru.timofeyco.justfeelbetter;

import java.util.ArrayList;
import java.util.Arrays;

import ru.timofeyco.justfeelbetter.adapters.TrainingDrillTypesAdapter;
import ru.timofeyco.justfeelbetter.db.JustFeelBetterDatabase;
import ru.timofeyco.justfeelbetter.model.DrillType;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ListView;

public class TrainingPrefDrillTypes extends ListActivity {
	JustFeelBetterDatabase dbHelper;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.training_drill_types);
		
		this.dbHelper = new JustFeelBetterDatabase(this);
				
		DrillType[] drillTypes = dbHelper.getDrillTypes();
    	ListView listView = this.getListView();
		if (listView != null) {		
			ArrayList<DrillType> drillTypesList = new ArrayList<DrillType>(Arrays.asList(drillTypes));
			listView.setAdapter(new TrainingDrillTypesAdapter(this, R.layout.training_drill_types_row, drillTypesList));					
		}    	
	}
}
